<?php
/**
 * 吐槽发帖发送消息
 * @author hjc19850430@gmail.com
 */
class ForumMsgtpl extends BaseMsgtpl
{
	/**
	 * 发帖分类下管理员发送消息
	 * @param array $wechatInfo		微信信息
	 * @param array $orderInfo		订单信息
	 * @param array $templet		报修模版配置信息oOwnZtwrlReqnJ2h5mmqTh3LGxmc
	 */
	public function sendMsg($forumInfo,$account_id,$forum_id,$user_id)
	{
//        $data1['content']=json_encode($forumInfo);
//        M('TestLog')->add($data1);
		$url = C('site_url').'/index.php?g=base&m=forum&a=detail&forum_id='.$forum_id.'&post_id='.$forumInfo['post_id'];
        $wechatUserInfo = D('Wechat/WechatUser')->getInfo(array('user_id' => $forumInfo['user_id']), 'openid,subscribe,wechat_id');

        if($account_id==1){
			$this->wxTplSign = 'QoyqfE9ayEaJAjtSr6AOpYWNdX93lxwyCBw19gGmbbo';
		}elseif($account_id == 5){//农林
			$this->wxTplSign = 'Z6Y6ISsWx8Nw568JKAIRy8ypjtqU5HQq5QfE4Gosuz0';
		}elseif($account_id == 25){//杭电
			$this->wxTplSign = 'ks1mAIs9QvmhHK9oCv48NV0VYr9V10CnI2zIAjCtQWQ';
		}elseif($account_id == 17){  //工商
			$this->wxTplSign = 'TGX60ttahLtLFrnkjXlowNxXSp0v_A-8MSUPyFT_3QQ';
		}elseif($account_id == 2){  //滨江
			$this->wxTplSign = 'asM-ofAPSgtvPgdljybiS0fQ9sn1vGHHzvvr7KmgGjU';
		}elseif($account_id == 47){//海宁医院
			$this->wxTplSign = '4Ovii0o5amdUVrFx_hD9IIWeBqE4dC1PJrvarih1P_Q';
		}elseif($account_id == 60){
				$this->wxTplSign = 'b927Utg2VSH5U2K1ivojHAGacjyUUt_s-i9GzjRTTzY';
        }elseif($account_id == 81){//杭千最美驿站
            $this->wxTplSign = 'ZSmpe7bezBKtKDRaQGnDjd0kiwvU_BJAN2wCVJN_DR4';
        }

		if($account_id == 47){
            $info = array(
                'first' => array("value" => '意见反馈通知！', 'color' => '#173177'),
                'keyword1' => array("value" => $forumInfo['type']),
                'keyword2' => array("value" => $forumInfo['content']),
                'keyword3' => array("value" => date("Y-m-d H:i:s",$forumInfo['create_time']), "color" => "#173177"),
                'remark' => array("value" => "请点击查看", "color" => "#173177")
            );
		}elseif($account_id == 60){
            $info = array(
                'first' => array("value" => '意见反馈通知！', 'color' => '#173177'),
                'keyword1' => array("value" => $forumInfo['type']),
                'keyword2' => array("value" => $forumInfo['content']),
                'keyword3' => array("value" => date("Y-m-d H:i:s"), "color" => "#173177"),
                'remark' => array("value" => "请点击查看", "color" => "#173177")
            );
		}elseif($account_id == 81){
            $nickname=D('Wechat/WechatUser')->where(array('user_id'=>$user_id))->getField('nickname');
            $info = array(
                'first' => array("value" => '意见反馈通知！', 'color' => '#173177'),
                'keyword1' => array("value" => $nickname),
                'keyword2' => array("value" => $forumInfo['content']),
                'keyword3' => array("value" => date("Y-m-d H:i:s",$forumInfo['create_time']), "color" => "#173177"),
                'remark' => array("value" => "请点击查看", "color" => "#173177")
            );
        }else{
			$info = array(
				'first' => array("value" => '意见反馈通知！', 'color' => '#173177'),
				'keyword1' => array("value" => $forumInfo['user_name']),
				'keyword2' => array("value" => $forumInfo['mobile']),
                'keyword3' => array("value" => $forumInfo['content']),
                'keyword4' => array("value" => date("Y-m-d H:i:s",$forumInfo['create_time']), "color" => "#173177"),
				'remark' => array("value" => "请点击查看", "color" => "#173177")
			);
		}
        $result = $this->wxObj->messageTpl($this->wechatInfo['appid'], $this->wechatInfo['appsecret'], $wechatUserInfo['openid'], $this->wxTplSign, $info, $url);
        return $result;
	}

}
